package com.pro.meeting.service.impl;

import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pro.meeting.bean.UserInfo;
import com.pro.meeting.dao.UserInfoDao;
import com.pro.meeting.service.UserInfoService;
@Service
public class UserInfoServiceImpl implements UserInfoService {
	@Autowired
	UserInfoDao userInfoDao;
	
	/* 添加微信用户个人信息*/
	@Override
	public int add(UserInfo u) {
	String uuid=UUID.randomUUID().toString();
		u.setWid(uuid);
		return userInfoDao.add(u);
	}

	@Override
	public int getUserInfoByOpenid(String openid) {
		// TODO Auto-generated method stub
		return userInfoDao.getUserInfoByOpenid(openid);
	}
	
	//取消关注时，根据openid修改关注状态
	// flag=0 后台更改其 subscribe为 0
	// flag=1后台更改其 subscribe为1
	@Override
	public int updateByOpenid(String openid,String flag) {
		// TODO Auto-generated method stub
		return userInfoDao.updateByOpenid(openid,flag);
	}

	//根据openid 得到wei_users对象
	@Override
	public UserInfo getByOpenid(String openid) {
		// TODO Auto-generated method stub
		return userInfoDao.getByOpenid(openid);
	}
	
	
	
}
